local sk__hechun = fk.CreateSkill {

  name = "sk__hechun",

  tags = {  },

}



sk__hechun:addEffect("active", {
  name = "sk__hechun",
  anim_type = "control",
  prompt = "#sk__hechun",
  card_num = 0,
  target_num = 0,
  can_use = function(self, player)
    return player:usedSkillTimes(sk__hechun.name, Player.HistoryPhase) == 0 and
      table.find(Fk:currentRoom().alive_players, function(p) return p ~= player and not p:isNude() end)
  end,
  card_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = effect.from
    local targets = room:getOtherPlayers(player)
    room:doIndicate(player.id, table.map(targets, Util.IdMapper))
    local black, red = {}, {}
    for _, target in ipairs(targets) do
      if player.dead then return end
      if not target.dead and not target:isNude() then
        local card = room:askForCard(target, 1, 1, true, sk__hechun.name, false, ".", "#sk__hechun-give:"..player.id)
        if Fk:getCardById(card[1]).color == Card.Black then
          table.insert(black, target)
        elseif Fk:getCardById(card[1]).color == Card.Red then
          table.insert(red, target)
        end
        room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonGive, sk__hechun.name, nil, true, target)
      end
    end
    if player.dead then return end
    local choice = room:askForChoice(player, {"sk__hechun_black", "sk__hechun_red", "Cancel"}, sk__hechun.name)
    if choice == "sk__hechun_black" then
      for _, p in ipairs(black) do
        if not p.dead then
          room:loseHp(p, 1, sk__hechun.name)
        end
      end
    elseif choice == "sk__hechun_red" then
      for _, p in ipairs(red) do
        if not p.dead and p:isWounded() then
          room:recover({
            who = p,
            num = 1,
            recoverBy = player,
            skillName = sk__hechun.name,
          })
        end
      end
    end
  end,
})

return sk__hechun